import type { ILoginAccountReq, ILoginResp, ILoginWechatMiniProgramReq } from '../types'
import { http } from '@/http/http'

export const LOGIN_BASE_API_URL = '/auth'
/**
 * 微信小程序登录接口
 * @param data ILoginWechatMiniProgramReq
 * @returns ILoginResp
 */
export function loginWechatMiniProgramApi(data: ILoginWechatMiniProgramReq) {
  return http<ILoginResp>({
    url: `${LOGIN_BASE_API_URL}/wechat-mini-program/login`,
    method: 'POST',
    data: {
      ...data,
    },
  })
}
/**
 * 账号密码登录接口
 * @param data ILoginAccountReq
 * @returns ILoginResp
 */
export function loginAccountApi(data: ILoginAccountReq) {
  return http<ILoginResp>({
    url: `${LOGIN_BASE_API_URL}/login`,
    method: 'POST',
    data: {
      ...data,
    },
  })
}

/**
 * 登出
 * @returns void
 */
export function logOutApi() {
  return http({
    url: `auth/logout`,
    method: 'POST',
  })
}
